package com.example.financecollegeorderdish.ui.dialog

import android.content.Context
import android.content.pm.PackageManager
import android.view.View
import android.widget.CheckBox
import android.widget.TextView
import com.blankj.utilcode.util.ClickUtils
import com.drake.brv.utils.grid
import com.drake.brv.utils.models
import com.drake.brv.utils.setup
import com.drake.channel.sendEvent
import com.drake.net.utils.TipUtils.toast
import com.example.financecollegeorderdish.R
import com.example.financecollegeorderdish.databinding.DialogInputBinding
import com.example.financecollegeorderdish.databinding.DialogMineralInputBinding
import com.example.financecollegeorderdish.databinding.DialogVitaminlInputBinding
import com.example.financecollegeorderdish.db.bean.DishBean
import com.example.financecollegeorderdish.db.bean.MineralBean
import com.example.financecollegeorderdish.db.bean.VitaminBean
import com.google.android.flexbox.FlexboxLayoutManager
import com.lxj.xpopup.core.CenterPopupView
import com.wuhao.lib_common.utils.NotNullHelper

/**
 * 旋转靶机
 */
class VitaminInputDialog(context: Context) : CenterPopupView(context) {
    val mBinding: DialogVitaminlInputBinding by lazy { DialogVitaminlInputBinding.bind(contentView) }

    /**
     * 具体实现的类的布局
     *
     * @return
     */
    override fun getImplLayoutId(): Int = R.layout.dialog_vitaminl_input

    /**
     * do init.
     */
    override fun onCreate() {
        super.onCreate()
        mBinding.btnOk.setOnClickListener {
            getVitaminData()
            dismiss()
        }
        mBinding.btnCancel.setOnClickListener { dismiss() }
    }


    private fun getVitaminData() {
        sendEvent(
            VitaminBean(
                getContent(mBinding.vitaminB1.text.toString()),
                getContent(mBinding.vitaminB2.text.toString()),
                getContent(mBinding.vitaminB3.text.toString()),
                getContent(mBinding.vitaminB5.text.toString()),
                getContent(mBinding.vitaminB7.text.toString()),
                getContent(mBinding.vitaminB9.text.toString()),
                getContent(mBinding.vitaminB12.text.toString()),
                getContent(mBinding.vitaminA.text.toString()),
                getContent(mBinding.vitaminD.text.toString()),
                getContent(mBinding.vitaminE.text.toString()),
                getContent(mBinding.vitaminK.text.toString()),
            )
        )

    }

    fun getContent(inputStr: String): String =
        if (NotNullHelper.notEmpty(inputStr)) {
            inputStr
        } else {
            ""
        }

}